<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  var str = "abc123dfh543dfgh986zxc123";

  // var reg = /\d+/g;
  // var reg = new RegExp("123", "g");
  // var reg = new RegExp("\\d+", "g");

  var msg = "\d";

  var reg = new RegExp("\\" + msg + "+", "g");
  console.log(reg);

  console.log( str.match(reg) );


  // console.log("hello \n world");
  // console.log("hello \\ world");
  // console.log("hello \ world");

  
</script>
</html>